#ifndef __RINGBUFFER_H
#define __RINGBUFFER_H

#include <stdint.h>
#include <string.h>
#include <stdio.h>


#define RingBuf_OK        0          //
#define RingBuf_ERROR    -1          // 
#define RingBuf_NOMEM    -2          // 
#define RingBuf_EMPTY    -3          // 

typedef struct 
{
    uint32_t xSize;             // 已存储的数据
    uint32_t xMAXItemSize;      // 最大尺寸

    uint8_t * pHead;            // 缓存的头指针
    uint8_t * pTail;            // 缓存的尾指针
    uint8_t * pWrite;           // 写入指针,指向待写入区域
    uint8_t * pRead;            // 读取指针,指向待读取区域
    /* data */
}RingBuffer_t;

// 使用静态内存创建环形缓存区
// arg：
extern int32_t RingBufferCreateStatie(RingBuffer_t * RingBuf_handle, uint8_t * Buffer, uint32_t BufferLen);

// 写入环形缓存区
extern int32_t RingBufferWrite(RingBuffer_t * RingBuf_handle, const void * data, uint32_t count);

// 读取环形缓存区
extern int32_t RingBufferRead(RingBuffer_t * RingBuf_handle, void * data, uint32_t count);

#endif

